<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<mat-menu
  #actions="matMenu"
  [classList]="'kd-user-panel'"
>
  <div
    class="kd-auth-status kd-muted"
    [ngClass]="hasAuthHeader() ? 'kd-auth-header' : ''"
  >
    <div
      fxFlex
      fxLayout="row"
    >
      <div
        fxFlex
        fxFlexAlign=" center"
        fxLayout="column"
        class="method kd-muted-light"
      >
        <ng-container
          *ngIf="hasAuthHeader()"
          i18n
          >Logged in with auth header
        </ng-container>
        <ng-container
          *ngIf="hasTokenCookie()"
          i18n
          >Logged in with token
        </ng-container>
        <span class="username kd-muted">{{ username }}</span>
      </div>

      <button
        mat-icon-button
        matTooltip="Close"
        i18n-matTooltip
        (click)="close()"
      >
        <mat-icon class="kd-muted">arrow_drop_up</mat-icon>
      </button>
    </div>
  </div>
  <mat-divider *ngIf="!hasAuthHeader()"></mat-divider>
  <button
    mat-menu-item
    *ngIf="!isAuthenticated()"
    (click)="logout()"
    i18n
  >
    Sign in
  </button>
  <button
    mat-menu-item
    *ngIf="isAuthenticated() && !hasAuthHeader()"
    (click)="logout()"
    i18n
  >
    Sign out
  </button>
</mat-menu>

<button
  mat-icon-button
  color="primary"
  [matMenuTriggerFor]="actions"
  (click)="$event.stopPropagation()"
>
  <mat-icon class="kd-user-panel-icon kd-primary-toolbar-icon">account_circle</mat-icon>
  <svg
    class="kd-cross-style"
    *ngIf="!isAuthenticated()"
    width="40px"
    height="40px"
    viewBox="0 0 40 40"
  >
    <line
      class="kd-cross-outline"
      x1="10"
      x2="30"
      y1="10"
      y2="30"
    />
    <line
      class="kd-cross-line-primary"
      x1="10"
      x2="30"
      y1="10"
      y2="30"
    />
  </svg>
</button>
